
/**
\file
Definition of the base sun::game_state class.
\author Sean Tromans
*/

#ifndef	SUN_GAME_STATE_HPP
#define	SUN_GAME_STATE_HPP

#include <sun/game_state/game_state_fwd.hpp>
#include <sun/time/time.hpp>
#include <sun/lua/lua_fwd.hpp>
#include <rainbow/viewport/viewport_stack.hpp>
#include <needs_more_ninja/interface.hpp>
#include <boost/enable_shared_from_this.hpp>

namespace sun
{

	/**
	Base game state class used by sun.
	Uses the Run and Return Successor state pattern.
	\author Sean Tromans
	*/
	class game_state :	public boost::enable_shared_from_this< game_state >,
						public nmn::interface_
	{
		//
		//	Public Member Functions
		//
		public:

			/**
			Updates the game state by \c delta_time.
			@param delta_time The time passed since the last update.
			@return The state which should replace this state next update.
			\author Sean Tromans
			*/
			virtual state_ptr step( time const & delta_time ) = 0;

			/**
			Called once before each frame is drawn. All required viewports should be pushed onto the viewport queue.
			@param step_fraction How far between logic updates this frame is.
			@param stack The stack of viewports being drawn so far this frame.
			\author Sean Tromans
			*/
			virtual void pre_draw( float step_fraction, rainbow::viewport_stack & stack ) = 0;

		//
		//	Static Member Functions
		//
		public:

			/**
			Exposes the \c game_state class to the lua state.
			@param L The lua_State being initialised.
			\author Sean Tromans
			*/
			static void lua_interface( lua_State * L );
	};

};

#endif	//SUN_GAME_STATE_HPP
